package com.cn.controller;

import com.cn.api.ApiResult;
import com.cn.pojo.shop.ShopCommodity;
import com.cn.pojo.vo.ShopCommodityVo;
import com.cn.service.ShopCommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * 商品
 */
@RestController
@RequestMapping("/commodity")
public class CommodityController {

    @Autowired
    private ShopCommodityService shopCommodityService;

    /**
     * 查询商品信息
     * @return
     */
    @GetMapping("/queryCommodity")
    public ApiResult queryCommodity(){
    return shopCommodityService.queryCommodity();
    }

    /**
     * 修改商品
     * @return
     */
    @PutMapping("/updateCommodity")
    public ApiResult updateCommodity(@RequestBody ShopCommodity shopCommodity,Integer id){
        return shopCommodityService.updateCommodity(shopCommodity,id);
    }

    /**
     * 删除商品信息
     * @param id
     * @return
     */
    @DeleteMapping("/deleteCommodity{id}")
    public ApiResult deleteCommodity(@PathVariable("id") Integer id){
        return shopCommodityService.deleteCommodity(id);
    }

    /**
     * 增加商品信息
     * @return
     */
    @PostMapping("/addCommodity")
    public ApiResult addCommodity(@RequestBody ShopCommodityVo shopCommodity){
        return shopCommodityService.addCommodity(shopCommodity);
    }

    /**
     * 查询商品信息
     * @return
     */
    @GetMapping("/selectCommodity")
    public ApiResult selectCommodity(){
        return shopCommodityService.selectCommodity();
    }
}
